package filter;

import org.apache.rocketmq.client.exception.MQBrokerException;
import org.apache.rocketmq.client.exception.MQClientException;
import org.apache.rocketmq.client.producer.DefaultMQProducer;
import org.apache.rocketmq.client.producer.SendResult;
import org.apache.rocketmq.common.message.Message;
import org.apache.rocketmq.remoting.exception.RemotingException;

/**
 * @Author if
 * @Description: What is it
 * @Date 2021-10-25 下午 10:43
 */
public class SQLFilterProducer {
    public static void main(String[] args) throws MQClientException, RemotingException, InterruptedException, MQBrokerException {
        DefaultMQProducer producer=new DefaultMQProducer("pg");
        producer.setNamesrvAddr("centos:9876");
        producer.start();

        for(int i=0;i<10;i++){
            byte[] body=("Hi,"+i).getBytes();
            Message msg=new Message("SQLFilterTopic","SQLFilterTopic",body);
            //在message中put用户属性
            msg.putUserProperty("age",i + "");
            SendResult sendResult = producer.send(msg);
            System.out.println(sendResult);
        }
        producer.shutdown();
    }
}
